import {
  Entity,
  PrimaryGeneratedColumn,
  CreateDateColumn,
  UpdateDateColumn,
  Column,
  ManyToMany,
} from "typeorm";
import { Goods } from "./Goods.entity";
// 商品分类
@Entity()
export class GoodsType {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({
    length: 50,
    comment: "商品分类名称",
  })
  name: string;

  @Column({
    length: 255,
    comment: "商品分类图片",
  })
  url: string;

  @Column({ comment: "商品分类父级id 一级为0", default: 0 })
  pid: number;

  @Column({
    length: 50,
    comment: "商品分类父级名称 一级为无",
    default: "无",
  })
  pname: string;

  @Column({ default: "", comment: "备注" })
  des: string;

  @CreateDateColumn({
    type: "datetime",
    comment: "创建时间",
  })
  create_at: Date;

  @UpdateDateColumn({
    type: "datetime",
    comment: "更新时间",
  })
  update_at: Date;

  @ManyToMany(() => Goods, (goods) => goods.goods_types)
  goods: Goods[];
}
